package com.ai.wx.main;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;

import org.apache.commons.lang.RandomStringUtils;

public class PromCodeGenerator {
	
	public static void main(String[] args) throws IOException {
		String code = "ABCDEFGHIJKMNOPQRSTUVWXYZ1234567890";
		HashSet<String> hs = new HashSet<String>();  
		while(hs.size() < 10000){
			String promCode = RandomStringUtils.randomAlphanumeric(4).toUpperCase().replaceAll("I", "1").replaceAll("O", "0");
			hs.add(promCode);
		}
		int id = 1;
		BufferedWriter output = new BufferedWriter(new FileWriter(new File("C:\\Users\\wangly\\Desktop\\promotioncode.sql"),true));
		for (String promCode : hs) {
			String sql = "insert into promotion_code_res (id,promotion_code,res_state,state,crt_date,crt_uid) values";

			sql +=  "("+id+",'"+promCode+"',1,1,now(),1);\n";
			 
			output.write(sql);
			id++;
		}
		output.close();
	}

}
